<% if $fetch_thread.alive? %>
  <div class="row">
    <div class="col-md-10">
      <div class="progress">
        <div class="progress-bar" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="width: <%= $fetch_thread[:completed].to_f*100.0/$fetch_thread[:followres_count].to_f %>%;">
          <span style="color:   #F4A460">
            <%= "#{$fetch_thread[:completed]}/#{$fetch_thread[:followres_count]}" %>
          </span> 
        </div>
      </div>
    </div>
    <div class="col-md-2">
      <%= link_to "取消",  admin_weixin_user_path(0), method: :delete, data: { confirm: '确定取消?' }  %>
    </div>
  </div>

  <script type="text/javascript">
    interval = setInterval(status, "3000");

    function status(){
      $.ajax({
       url: '/admin/weixin/users/0',
       type: 'PUT',
       success: function(response) {
          $('.progress-bar').css('width', response.completed/response.followres_count*100 + "%")
          $('.progress-bar span').html(response.completed+'/'+response.followres_count)
          if(response.completed >= response.followres_count){
            clearInterval(interval)
            window.location.reload();
          }
        }
      });
    }
    
  </script>
<% end %>